//
//  ZXZOrderHireViewController.m
//  sheyingzu
//
//  Created by tyu on 29.5.24.
//

#import "ZXZOrderHireViewController.h"


#import "ZXZOrderCell.h"
#import "ZXZMyTopView.h"

@interface ZXZOrderHireViewController ()

@property(nonatomic,weak) UIScrollView *ScrollView;

@property(nonatomic,weak) UIView *topView;
@property(nonatomic,weak) UITextView *TitleTextView;
@property(nonatomic, weak)UILabel *placeHolder;


@property(nonatomic,weak) UIView *middView;
@property(nonatomic,weak) UITextField *dayTextF;

@property(nonatomic,weak) ZXZOrderCell *cell1;
@property(nonatomic,weak) ZXZOrderCell *cell2;

@property(nonatomic,weak) UIView *bottomView;
@property(nonatomic,weak) UITextField *phoneTextF;


@end

@implementation ZXZOrderHireViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)alipaySuccessAction:(NSNotification *)note
{
    // 支付成功，返回首页
    [self.navigationController popToRootViewControllerAnimated:YES];
}


- (void)bac_addUI
{
    [super bac_addUI];
    [self setupView];
    self.bacTitleLabel.text = @"收银台";
    [self.view bringSubviewToFront:self.navView];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(alipaySuccessAction:) name:ZXZAlipaySuccessNotification object:nil];

    
}
- (void)hireBtnClick
{
    
    [ZXZNetworkRequest getorderStart:self.totalStr];
    
}


- (void)setupView{
    
    UIScrollView *ScrollV = [[UIScrollView alloc]init];
    [self.view addSubview:ScrollV];
    self.ScrollView =ScrollV;

    ScrollV.contentSize = CGSizeMake(ScreenWidth, ScreenHeight*1.1);
    ScrollV.contentInset = UIEdgeInsetsMake(0, 0, -10, 0);
    ScrollV.showsVerticalScrollIndicator = NO;
    ScrollV.frame = CGRectMake(0, 100, ScreenWidth, ScreenHeight-ShowDiff);
    
    [self setTopView];
    [self setupMiddView];
    [self setupBottomView];
    
    
    
      UIButton *hireBtn = [[UIButton alloc] init];
      [self.view addSubview:hireBtn];
      hireBtn.frame = CGRectMake(20, ScreenHeight-twoShowDiff-50, ScreenWidth-44, 44);

      [hireBtn setTitle:@"立即支付" forState:UIControlStateNormal];
      hireBtn.backgroundColor = [UIView ColorWithHexString:@"#07C6D2"];
      [hireBtn addTarget:self action:@selector(hireBtnClick) forControlEvents:UIControlEventTouchUpInside];
      hireBtn.layer.cornerRadius = 44/2;
      hireBtn.layer.masksToBounds = YES;
      

    
}


- (void)setTopView
{
    
    UIView *view = [UIView new];
    [self.ScrollView addSubview:view];
    self.topView =view;
    view.frame = CGRectMake(0, 20, ScreenWidth, 100);
    view.backgroundColor = [UIColor whiteColor];
 
    UILabel *Title  = [UIView lableWithText:@"需支付金额" andColor:[UIView ColorWithHexString:@"#666666"] andFont:14];
    [view addSubview:Title];
    Title.textAlignment = NSTextAlignmentCenter;
    
    Title.frame = CGRectMake(0, 10, ScreenWidth, 20);

    UILabel *totalLab  = [UIView lableWithText:[NSString stringWithFormat:@"￥%@.00",self.totalStr] andColor:[UIView ColorWithHexString:@"#FA4747"] andFont:14];
    [view addSubview:totalLab];
    totalLab.font = [UIFont boldSystemFontOfSize:30];
    totalLab.textAlignment = NSTextAlignmentCenter;

    totalLab.frame = CGRectMake(0, CGRectGetMaxY(Title.frame)+5, ScreenWidth, 30);

}




- (void)setupMiddView
{
    
    UIView *view = [UIView new];
    [self.ScrollView addSubview:view];
    self.middView =view;
    view.frame = CGRectMake(15, CGRectGetMaxY(self.topView.frame)+10, ScreenWidth-30, 120);
    view.backgroundColor = [UIView ColorWithHexString:@"#FAFAFA"];
    view.layer.cornerRadius = 5;
    view.layer.masksToBounds = YES;
    
    
    UILabel *leftTitle  = [[UILabel alloc]init];
    [view addSubview:leftTitle];
    leftTitle.font = [UIFont systemFontOfSize:16];
    leftTitle.textColor = [UIColor blackColor];
    leftTitle.text = @"费用明细";
    leftTitle.frame = CGRectMake(10, 10, 90, 20);
    
    ZXZOrderCell *cell = [ZXZOrderCell new];
    [view addSubview:cell];
    cell.TitleLab.text = @"金额";
    cell.subLab.text = [NSString stringWithFormat:@"￥%@",self.totalStr];
    self.cell1 = cell;
    
    
    ZXZOrderCell *cell2 = [ZXZOrderCell new];
    [view addSubview:cell2];
    cell2.TitleLab.text = @"运费";
    cell2.subLab.text = @"￥0";
    self.cell2 = cell2;

    
    CGFloat width = ScreenWidth-30;
    CGFloat height = 40;
    self.cell1.frame = CGRectMake(0,  CGRectGetMaxY(leftTitle.frame)+10, width, height);
    self.cell2.frame = CGRectMake(0, CGRectGetMaxY(self.cell1.frame), width, height);
    
    
}


- (void)setupBottomView
{
    
    ZXZMyTopView *leftView = [[ZXZMyTopView alloc]init];
    [self.ScrollView addSubview:leftView];
    leftView.TitleLab.text = @"支付宝支付";
    leftView.leftImageV.image = [UIImage imageNamed:@"hire_image"];
    leftView.ImgV.image = [UIImage imageNamed:@"hire_image_sel"];
    leftView.frame = CGRectMake(15, CGRectGetMaxY(self.middView.frame)+10, ScreenWidth-30, 50);
    leftView.ContentV.backgroundColor = [UIView ColorWithHexString:@"#FAFAFA"];

    leftView.layer.cornerRadius = 5;
    leftView.layer.masksToBounds = YES;
    
}

- (UILabel *)lableWithText:(NSString *)title andColor:(UIColor *)color andFont:(CGFloat )font
{
    
    UILabel *rightTitle  = [[UILabel alloc]init];
    rightTitle.font = [UIFont systemFontOfSize:font];
    rightTitle.textColor = color;
    rightTitle.text = title;
    return rightTitle;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];

}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self.view endEditing:YES];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
